package com.ff.device.result;

import lombok.ToString;

@ToString
public class CodeMsg {

    private int code;

    private String msg;

    public static CodeMsg SUCCESS=new CodeMsg(0,"success");

    //通用异常
    public static CodeMsg SERVER_ERROR=new CodeMsg(500100,"服务端异常");
    public static CodeMsg BIND_ERROR=new CodeMsg(500101,"异常：%s");

    //登录模块 5002XX
    public static CodeMsg MOBILE_NOT_EXIST=new CodeMsg(500201,"手机号不存在");
    public static CodeMsg PASSWORD_ERROR=new CodeMsg(500201,"密码错误");
    public static CodeMsg SESSION_ERROR=new CodeMsg(500202,"session异常");
    public static CodeMsg ACCESS_LIMIT_REACHED =new CodeMsg(500203,"访问太频繁，请稍后再试");

    //设备模块5003XX
    public static CodeMsg DEVICE_UPDATE_FAILURE=new CodeMsg(500300,"设备更新失败");
    public static CodeMsg DEVICE_ADD_FAILURE=new CodeMsg(500301,"由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。");
    public static CodeMsg DEVICE_NOT_FOUND=new CodeMsg(500302,"设备未找到");
    public static CodeMsg DEVICE_GET_FAILUE=new CodeMsg(500303,"获取设备列表异常");
    public static CodeMsg DEVICE_DELETE_FAILUE=new CodeMsg(500304,"删除设备失败");
    public static CodeMsg DEVICE_PRARM_UNCORRECT=new CodeMsg(500305,"设备ID不正确");

    //任务5004XX
    public static CodeMsg GET_TASK_FAILURE =new CodeMsg(500400,"获取任务失败");
    public static CodeMsg UPDATE_TASK_FAILURE =new CodeMsg(500401,"更新任务失败");
    public static CodeMsg SAVE_TASK_FAILURE =new CodeMsg(500402,"新增任务失败");
    public static CodeMsg DELETE_TASK_FAILURE =new CodeMsg(500403,"删除任务失败");

    //上传下载5005XX
    public static CodeMsg UPLOAD_RESULT_FAULURE=new CodeMsg(500501,"结果上传失败");
    public static CodeMsg UPLOAD_FILE_EMPTY=new CodeMsg(500502,"上传文件不能为空");
    public static CodeMsg UPLOAD_CONTENT_FAILURE=new CodeMsg(500503,"结果上传内容不正确");
    public static CodeMsg UPLOAD_FILE_FORMAT_FAILURE=new CodeMsg(500504,"文件格式错误");
    public static CodeMsg DOWNLOAD_SCRIPT_NOT_FOUND=new CodeMsg(500505,"下载文件没找到");

    //心跳异常5006XX
    public static CodeMsg HEART_BEAT_FAILURE=new CodeMsg(500601,"获取心跳异常");

    //脚本5007XX
    public static CodeMsg DELETE_SCRIPT_FAILURE=new CodeMsg(500701,"删除脚本异常");

    //项目-模块列表
    public static CodeMsg MODULE_SAVE_FAILUE=new CodeMsg(500801,"新增模块失败");
    public static CodeMsg MODULE_UPDATE_FAILUE=new CodeMsg(500802,"更新模块失败");
    public static CodeMsg MODULE_GET_FAILUE=new CodeMsg(500803,"获取模块列表失败");

    public static CodeMsg PROJECT_SAVE_FAILUE=new CodeMsg(500805,"新增项目失败");
    public static CodeMsg PROJECT_UPDATE_FAILUE=new CodeMsg(500805,"更新项目失败");
    public static CodeMsg PROJECT_PRRAM_UNCORRECT=new CodeMsg(500806,"获取项目参数失败");
    public static CodeMsg PROJECT_HAS_SUBMODULE=new CodeMsg(500807,"项目有子模块,暂不能删除");

    private CodeMsg(int code, String msg){
        this.code=code;
        this.msg=msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public CodeMsg fillArgs(Object... args){
        int code=this.code;
        String message=String.format(this.msg,args);
        return new CodeMsg(code,message);
    }

}
